include .env
REPO?=registry.cn-hangzhou.aliyuncs.com/bi-service
FLINK_VERSION?=1.20.0
FLINK_CDC_VERSION?=3.3.0

NAMESPACE?=flink
export
.PHONY: build push template_config config install_cdc teardown_cdc

build:
	docker build -t ${REPO}/flink-cdc-pipeline:${FLINK_VERSION} \
		--build-arg FLINK_VERSION=${FLINK_VERSION} \
		--build-arg FLINK_CDC_VERSION=${FLINK_CDC_VERSION} \
		--no-cache .

push: build
	docker push ${REPO}/flink-cdc-pipeline:${FLINK_VERSION}

template_config:
	-mkdir -p build
	envsubst < deploy/mysql-to-starrocks-pipeline-configmap.yaml > build/mysql-to-starrocks-pipeline-configmap.yaml

config:
	-mkdir -p build
	envsubst < deploy/mysql-to-starrocks-pipeline-configmap.yaml > build/mysql-to-starrocks-pipeline-configmap.yaml
	kubectl apply -f build/mysql-to-starrocks-pipeline-configmap.yaml -n ${NAMESPACE}

install_cdc: config
	-mkdir -p build
	envsubst < deploy/mysql-to-starrocks-pipeline-cdc-job.yaml > build/mysql-to-starrocks-pipeline-cdc-job.yaml
	kubectl apply -f build/mysql-to-starrocks-pipeline-cdc-job.yaml -n ${NAMESPACE}

teardown_cdc:
	kubectl delete -f build/mysql-to-starrocks-pipeline-cdc-job.yaml -n ${NAMESPACE}